package com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.supplier;

import com.iwhalecloud.bss.kite.common.util.KiteMapUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.UserAttrSupplier;
import com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.UserInfoHelper;
import com.iwhalecloud.bss.kite.dataservice.cache.AttrValueCache;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * 是否执行信控
 */
@Service
@UserAttrSupplier(attrField = "USR0016")
public class ExcuteInformationControlSupplier extends AbstractUserAttrSupplier {

    @Override
    public String getValue() {
        String isExcuteInforMationControl = UserInfoHelper
            .getValueFromUserItemInfoMap(userInfoContext.getUserItemInfoMap(), LocalKeyConsts.IS_EXCUTE_INFORMATIONCONTROL);
        return isExcuteInforMationControl;
    }

    @Override
    public String getValueDesc() {
        String excuteInformationControlVal = getValue();
        return Optional.ofNullable(AttrValueCache.getAttrValue("230000625", excuteInformationControlVal))
            .map(AttrValue::getAttrValueName).orElse(excuteInformationControlVal);
    }
}
